package com.coffee.service.impl;

import com.coffee.conmmon.BaseResult;
import com.coffee.dao.ShomeDaoMapper;
import com.coffee.entity.Shome;
import com.coffee.service.ShomeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class ShomeServiceImpl implements ShomeService {

    @Resource
    ShomeDaoMapper shomeDaoMapper;

    @Override
    public BaseResult findAll() {
        List<Shome> shomes = shomeDaoMapper.findAll();
        BaseResult baseResult = new BaseResult();
        if(shomes!=null){
            baseResult.setCode(200);
            baseResult.setData(shomes);
            baseResult.setMessage("查找成功");
            return baseResult;
        }
        baseResult.setMessage("查找失败");
        baseResult.setCode(201);
        return baseResult;
    }

    @Override
    public BaseResult findAllByHid(Integer hid) {
        BaseResult baseResult = new BaseResult();
        Shome allByHid = shomeDaoMapper.findAllByHid(hid);
        if(allByHid!=null){
            baseResult.setCode(200);
            baseResult.setData(allByHid);
            baseResult.setMessage("查找成功");
            return baseResult;
        }
        baseResult.setMessage("查找失败");
        baseResult.setCode(201);
        return baseResult;
    }
}
